@extends('admin.pub.pub')
@section('title','角色列表')
@section('bread1','角色管理')
@section('bread2','角色添加')
@section('content')
    <div class="container">
        <form method="post" role="form" class="form-horizontal">
            <div class="form-group">
                <label for="rolename">角色名称</label>
                <input type="text" class="input-text" name="name" id="rolename">
            </div>
            <button id="add" class="btn btn-primary">添加</button>
        </form>
    </div>
@endsection
@section('js')
    <script>
		$('#add').click(function (e) {

			let name = $('#rolename').val();
			let _token = '{{ csrf_token() }}'
			$.ajax({
				url: '{{ route('admin.role.store') }}',
				type: 'post',
				data: {name, _token},
				dataType: 'json',
				success(res) {
					if (res.status == 0) {
						$('#rolename').val('')
						layer.msg('成功')
					} else {
						layer.alert('失败')
					}
				},
				error(obj) {
					let error = JSON.parse(obj.responseText)
					console.log(error)
				}
			})
			return false;
		})
    </script>
@endsection